<?php
include_once('class/autoload.php');

require_once'MyPDO.php';
require_once 'PreparationREQ.php';
$site = new page_base('inscription');
$site->titre = "Inscription des �l�ves";
$categ='';
$typeSexe='';

try
{
	$db= new MyPDO('mysql:host=localhost;dbname=bd_usep_ppe','root','');

	$PrepREQ = new PreparationREQ($db);
	
	if(isset ($_POST['radiogoupe']))
	{
		if($_POST['radiogoupe']=='5')
		{
			$typeSexe='Gar�on';
		}
		if($_POST['radiogoupe']=='3')
		{
			$typeSexe='Fille';
		}
	}
	
	if(isset ($_POST['categ']))
	{
		if($_POST['categ']=='1')
		{
			$categ='A';
		}
		if($_POST['categ']=='2')
		{
			$categ='B';
		}
	}
	
	$PrepREQ->insert($_POST['firstname'], $_POST['lastname'],$_POST['date'] ,$typeSexe,$categ);
	
	echo 'L\'inscription a &eacute;t&eacute; faite avec succ&egrave;s !';
	header('Location : index.php');
}
catch (Exception $e)
{
	die('Erreur : ' . $e->getMessage());

}

$site->affiche();
?>